﻿//-----------------------------------------------------------------------
// <copyright file="Message.cs" company="AFS">
// Copyright (c) AFS. All rights reserved.
//
//    This file is part of Chatbox.
//
//    Chatbox is free software: you can redistribute it and/or modify
//    it under the terms of the GNU Lesser General Public License as published by
//    the Free Software Foundation, either version 3 of the License, or
//    any later version.
//
//    Chatbox is distributed in the hope that it will be useful,
//    but WITHOUT ANY WARRANTY; without even the implied warranty of
//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
//    GNU Lesser General Public License for more details.
//
//    You should have received a copy of the GNU Lesser General Public License
//    along with Chatbox. If not, see http://www.gnu.org/copyleft/lesser.html
// </copyright>
//----------------------------------------------------------------------- 

namespace ChatBox.DomainObjects.XmlFeedObjects
{
    using System;

    using ChatBox.DomainObjects.MessageTypes;

    /// <summary>
    /// Defines an event that receives a message
    /// </summary>
    /// <param name="sender">the event sender</param>
    /// <param name="message">the message sent</param>
    public delegate void MessageEvent(object sender, Message message);

    /// <summary>
    /// A public chat or private message
    /// </summary>
    public class Message
    {
        /// <summary>
        /// Gets or sets the numeric identifier of the message
        /// </summary>
        public int Id { get; set; }
        
        /// <summary>
        /// Gets or sets the user who sent the message
        /// </summary>
        public Link From { get; set; }

        /// <summary>
        /// Gets or sets the group that the message was sent to can be null
        /// </summary>
        public Link Group { get; set; }

        /// <summary>
        /// Gets or sets the raw content of the message
        /// </summary>
        public string RawMessageText { get; set; }

        /// <summary>
        /// Gets or sets the content of the message after processing
        /// </summary>
        public string MessageText { get; set; }

        /// <summary>
        /// Gets or sets the typoe of message text
        /// </summary>
        public MessageType MessageType { get; set; }

        /// <summary>
        /// Gets or sets when the message was sent
        /// </summary>  
        public DateTime Sent { get; set; }

        /// <summary>
        /// Gets or sets a value indicating whether the message is public
        /// </summary>
        public bool IsPublic { get; set; }

        /// <summary>
        /// Display for debug
        /// </summary>
        /// <returns>text describing the value</returns>
        public override string ToString()
        {
            return this.Id + " " + this.Sent + " " + this.From.Text + " " + this.RawMessageText;
        }
    }
}
